/**
******************************************************************************
* @file ADPCM/inc/adpcm.h
* @author  MCD Application Team
* @version  V2.0.0
* @date  04/27/2009
* @brief  Header file for adpcm.c
******************************************************************************
* @copy
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>&copy; COPYRIGHT 2009 STMicroelectronics</center></h2>
*/


/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __ADPCM_H
#define __ADPCM_H

/* Includes ------------------------------------------------------------------*/
//#include "stm32f10x.h"
#include <_types.h>

typedef struct {
    uint32_t rId;    //标志符（RIFF）
    uint32_t rLen;   //数据大小,包括数据头的大小和音频文件的大小
    uint32_t wId;    //格式类型（"WAVE"）
    uint32_t fId;    //"fmt"
    uint32_t fLen;   //Sizeof(WAVEFORMATEX)
    uint16_t wFormatTag;       //编码格式，包括WAVE_FORMAT_PCM，WAVEFORMAT_ADPCM等
    uint16_t nChannels;        //声道数，单声道为1，双声道为2
    uint32_t nSamplesPerSec;   //采样频率
    uint32_t nAvgBytesPerSec;  //每秒的数据量
    uint16_t nBlockAlign;      //块对齐
    uint16_t wBitsPerSample;   //WAVE文件的采样大小
} TWaveHeader;

typedef uint32_t DWORD;
typedef uint8_t BYTE;
typedef uint16_t WORD;

struct tagHXD_WAVFLIEHEAD {
    char RIFFNAME[4];
    DWORD nRIFFLength;
    char WAVNAME[4];
    char FMTNAME[4];
    DWORD nFMTLength;
    WORD nAudioFormat;

    WORD nChannleNumber;
    DWORD nSampleRate;
    DWORD nBytesPerSecond;
    WORD nBytesPerSample;
    WORD nBitsPerSample;
    char DATANAME[4];
    DWORD nDataLength;
};

typedef struct tagHXD_WAVFLIEHEAD HXD_WAVFLIEHEAD;

typedef struct {
    uint32_t len;
    uint32_t flag;
    uint32_t samples_per_sec;
    uint32_t fid;
    char name[16];
    uint8_t *pdata;
} TADPCMFileData;


/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void CompressBuff(uint8_t *inbuf, uint32_t inbuf_len, uint8_t *outbuf, uint32_t outbuf_len);

uint32_t CompressFile(uint8_t *filebuf, uint32_t buf_len, uint8_t *outbuf, uint32_t outbuf_len);

uint8_t ADPCM_Encode(int32_t sample, int reset);

int16_t ADPCM_Decode(uint8_t code, uint8_t flag);

#endif /* __ADPCM_H*/
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
